<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../../../../assets/libs/jquery/jquery-3.6.1.min.js"></script>
</head>

<body>
  <form>
    <input type="text" name="username">
    <input type="text" name="password">
    <input type="submit" value="提交">
  </form>

  <script>
    $('form').submit(event => {
      event.preventDefault()

      // 获取表单数据
      const data = $('form').serialize()
      console.log(data) // username=%E5%BC%A0%E6%99%BA%E7%90%A6&password=123456
    })
  </script>
</body>

</html>